import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import element from "element-plus"
import 'element-plus/theme-chalk/index.css'
import "./index.css"
import "@/styles/index.scss"
import './mock'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const app = createApp(App)
app.use(store)
app.use(router)
app.use(element)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }
app.mount('#app')
app.config.globalProperties.$axios = axios
// 全局挂载vuex
app.config.globalProperties.$store=store
app.config.globalProperties.$filters={
  dateFormat(originVal){
    const dt = new Date(originVal)

    const y = dt.getFullYear()
    // padStart 填充到多少位，填充内容为'0'
    const M = (dt.getMonth() + 1 + '').padStart(2, '0');
    const d = (dt.getDate() + '').padStart(2, '0');
    const h = (dt.getHours()+'').padStart(2, '0');
    const m = (dt.getMinutes() + '').padStart(2, '0');
    const s = (dt.getSeconds() + '').padStart(2, '0');
    return `${y}-${M}-${d} ${h}:${m}:${s}`
  },
  dayFormat(originVal){
    const dt = new Date(originVal)
    const y = dt.getFullYear()
    // padStart 填充到多少位，填充内容为'0'
    const M = (dt.getMonth() + 1 + '').padStart(2, '0');
    const d = (dt.getDate() + '').padStart(2, '0');
    return `${y}-${M}-${d}`
  },
  drugTypeFormat(key){
    const list = store.state.pharmacyOptions.codeNames
    var flag = false;
    for(let i=0;i<list.length;i++){
      const item =list[i]
      if(item.type=='drugType'&&item.key==key){
      flag=true
      return item.value}
    }
    if(flag == false) return"量子纠缠类型";
  },
  unitFormat(key){
    const list = store.state.pharmacyOptions.codeNames
    var flag = false;
    for(let i=0;i<list.length;i++){
      const item =list[i]
      if(item.type=='unit'&&item.key==key){
      flag=true
      return item.value}
    }
    if(flag == false) return"量子纠缠规格";
  },
  payStatusFormat(key){
    const list = store.state.pharmacyOptions.codeNames
    var flag = false;
    for(let i=0;i<list.length;i++){
      const item =list[i]
      if(item.type=='payStatus'&&item.key==key){
      flag=true
      return item.value}
    }
    if(flag == false) return"量子纠缠缴费";
  },
  deliveryStatusFormat(key){
    const list = store.state.pharmacyOptions.codeNames
    var flag = false;
    for(let i=0;i<list.length;i++){
      const item =list[i]
      if(item.type=='deliveryStatus'&&item.key==key){
      flag=true
      return item.value}
    }
    if(flag == false) return"量子纠缠发放";
  }
}


